Добрый день.
Есть функция, которая должна вызывать сама себя каждую секунду. Но она вызывается гораздо чаще. Не могу понять в чем дело.
В файле tester.php просто цифра 1.
<?php
$flotsel=8;
?><!DOCTYPE html>
<html>
<head>
<title>Использование метода .getJSON()</title>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script>
var pointarr = 0
function requestData(flotSel) {
var d = new Date();
dataTek = d.toString()
console.log('Zagruzka - flotSel=', flotSel, 'dataTek=', dataTek)
$.getJSON('../tester.php?flotsel=' + flotSel, function (pointarr) {
console.log('pointarr=', pointarr)
// call it again after one second
setTimeout(requestData(flotSel), 1000);
});
}
flotSel = 8 + pointarr
da = requestData(flotSel)
</script>
</head>
<body>
</body>
</html>